package com.zhr.handler;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.zhr.bean.Music;
import com.zhr.server.WeixinRequest;
import com.zhr.server.WeixinResponse;
import com.zhr.type.MsgType;

public class MessageMusicHandler extends MessageAbstractHandler {

	private final Pattern musicRequestPattern = Pattern.compile("(.+)-(.+)");

	@Override
	public WeixinResponse handle(WeixinRequest request) {
		WeixinResponse response = super.handle(request);
		response.setMsgType(MsgType.music.name());
		Music music = new Music();
		music.setTitle("走慢一点点");
		music.setDescription("张震岳-走慢一点点");
		music.setMusicUrl("http://zhangmenshiting.baidu.com/data2/music/64352660/641138001372978861128.mp3?xcode=c43cd23f24570b002f06e4ddf7446bda98b46db35d8e5692");
		music.setHQMusicUrl("http://zhangmenshiting.baidu.com/data2/music/64352641/641138001372978861320.mp3?xcode=c43cd23f24570b002f06e4ddf7446bda647c6966174acbbc");
		response.setMusic(music);
		response.setFuncFlag("0");
		return response;
	}

	@Override
	public int getPriority() {
		return MAX_PRIORITY;
	}

	@Override
	public boolean accpet(WeixinRequest request) {
		Matcher matcher = musicRequestPattern.matcher(request.getContent());
		return matcher.find();
	}

}
